# -*- coding: utf-8 -*-
"""
Created on Sun Apr  2 13:40:51 2017
euler project 50
@author: zhiqiang
"""
import time
t0 = time.time()
from euler49 import is_prime

n = 21
under_lim = 953
primes = [2]
for i in range(3,999999,2):
    if is_prime(i):
        primes.append(i)

t2 = time.time()
len_primes = len(primes)    
#####方法1：正面求解
max_num = 0
for i in range(22,len_primes):
    break_iner_loop = False
    for j in range(i + 1):
        tmp_sum = sum(primes[j:j+i])
        if tmp_sum>=999999:
            break
        if tmp_sum not in primes:
            continue
        else:
            break_iner_loop = True
            max_num = tmp_sum
            break
print(primes[j:j+i])
print(max_num)
t3 = time.time()
#####方法2：反面求解
for i in range(len_primes):
    lens = len_primes - i
    break_iner_loop = False
    for j in range(lens + 1):
        tmp_sum = sum(primes[j:j+lens])
        if tmp_sum >= 999999:
            break
        if tmp_sum not in primes:
            continue
        else:
            print(tmp_sum)
            print(primes[j:j+lens])
            break_iner_loop = True
            break
    if break_iner_loop:
        break
t1 = time.time()
print(t1 - t3)
print(t3 - t2)